//### This file created by BYACC 1.8(/Java extension  1.15)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97  -- Bob Jamison, Joe Nieten
//###           01 Jan 98  -- Bob Jamison -- fixed generic semantic constructor
//###           01 Jun 99  -- Bob Jamison -- added Runnable support
//###           06 Aug 00  -- Bob Jamison -- made state variables class-global
//###           03 Jan 01  -- Bob Jamison -- improved flags, tracing
//###           16 May 01  -- Bob Jamison -- added custom stack sizing
//###           04 Mar 02  -- Yuval Oren  -- improved java performance, added options
//###           14 Mar 02  -- Tomas Hurka -- -d support, static initializer workaround
//### Please send bug reports to tom@hukatronic.cz
//### static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";



package Parser;



//#line 2 "GramaticaFinal.y"
import Lexico.AnalizadorLexico;
import Mensajes.Mensaje;
import PolacaInversa.Polaca;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Observable;
import TablaDeSimbolos.TSimbolo;
import TokensDelLenguaje.*;
import java.util.ArrayList;
import java.util.Iterator;


//#line 30 "Parser.java"




public class Parser
             extends Observable
             implements ParserTokens,ParserTokens
{

boolean yydebug;        //do I want debug output?
int yynerrs;            //number of errors so far
int yyerrflag;          //was there an error?
int yychar;             //the current working character

//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
  if (yydebug)
    System.out.println(msg);
}

//########## STATE STACK ##########
final static int YYSTACKSIZE = 500;  //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax;                     //highest index of stackptr
int statemax;                        //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
  try {
		stateptr++;
		statestk[stateptr]=state;
	 }
	 catch (ArrayIndexOutOfBoundsException e) {
     int oldsize = statestk.length;
     int newsize = oldsize * 2;
     int[] newstack = new int[newsize];
     System.arraycopy(statestk,0,newstack,0,oldsize);
     statestk = newstack;
     statestk[stateptr]=state;
  }
}
final int state_pop()
{
  return statestk[stateptr--];
}
final void state_drop(int cnt)
{
  stateptr -= cnt; 
}
final int state_peek(int relative)
{
  return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
  stateptr = -1;
  val_init();
  return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
  System.out.println("=index==state====value=     s:"+stateptr+"  v:"+valptr);
  for (i=0;i<count;i++)
    System.out.println(" "+i+"    "+statestk[i]+"      "+valstk[i]);
  System.out.println("======================");
}


//########## SEMANTIC VALUES ##########
//public class ParserVal is defined in ParserVal.java


String   yytext;//user variable to return contextual strings
ParserVal yyval; //used to return semantic vals from action routines
ParserVal yylval;//the 'lval' (result) I got from yylex()
ParserVal valstk[];
int valptr;
//###############################################################
// methods: value stack push,pop,drop,peek.
//###############################################################
void val_init()
{
  valstk=new ParserVal[YYSTACKSIZE];
  yyval=new ParserVal();
  yylval=new ParserVal();
  valptr=-1;
}
void val_push(ParserVal val)
{
  if (valptr>=YYSTACKSIZE)
    return;
  valstk[++valptr]=val;
}
ParserVal val_pop()
{
  if (valptr<0)
    return new ParserVal();
  return valstk[valptr--];
}
void val_drop(int cnt)
{
int ptr;
  ptr=valptr-cnt;
  if (ptr<0)
    return;
  valptr = ptr;
}
ParserVal val_peek(int relative)
{
int ptr;
  ptr=valptr-relative;
  if (ptr<0)
    return new ParserVal();
  return valstk[ptr];
}
final ParserVal dup_yyval(ParserVal val)
{
  ParserVal dup = new ParserVal();
  dup.ival = val.ival;
  dup.dval = val.dval;
  dup.sval = val.sval;
  dup.obj = val.obj;
  return dup;
}
//#### end semantic value section ####
public final static short YYERRCODE=256;
final static short yylhs[] = {                           -1,
    0,    0,    0,    0,    0,    4,    4,    5,    5,    5,
    5,    5,    1,    1,    7,    1,    6,    6,    6,    6,
   10,   10,    8,    8,    8,    8,    9,    9,    9,    9,
    2,    2,   12,    2,    3,    3,   11,   14,   11,   11,
   11,   11,   11,   11,   13,   23,   15,   24,   15,   15,
   25,   27,   22,   22,   22,   22,   26,   26,   19,   19,
   20,   20,   20,   20,   20,   29,   29,   29,   29,   29,
   30,   30,   30,   30,   30,   30,   30,   28,   32,   32,
   31,   31,   21,   21,   21,   21,   21,   21,   21,   33,
   33,   33,   33,   33,   33,   17,   18,   18,   18,   18,
   18,   16,   35,   34,   37,   36,   38,   38,   38,   38,
};
final static short yylen[] = {                            2,
    2,    1,    3,    2,    1,    1,    1,    5,    4,    5,
    5,    3,    1,    2,    0,    4,    2,    2,    2,    3,
    1,    3,    2,    3,    2,    1,    2,    3,    2,    1,
    1,    2,    0,    4,    1,    2,    2,    0,    3,    1,
    1,    2,    1,    2,    3,    0,    5,    0,    4,    2,
    0,    0,    5,    1,    2,    1,    1,    1,    1,    1,
    1,    3,    3,    3,    3,    1,    3,    3,    3,    3,
    1,    1,    1,    3,    3,    3,    2,    3,    1,    3,
    1,    1,    5,    3,    5,    5,    4,    3,    3,    1,
    1,    1,    1,    1,    1,    4,    4,    4,    4,    3,
    2,    5,    0,    6,    1,    3,    1,    1,    1,    1,
};
final static short yydefred[] = {                         0,
    0,    0,    0,    0,    0,    0,   35,    0,    6,    0,
    0,    2,    0,    5,    0,   13,    0,    0,   31,    0,
   40,   41,    0,    0,    0,   60,   50,   82,   81,    0,
    0,    0,    0,    0,   73,    0,   66,   72,    0,  101,
    0,    0,    0,   23,   27,   21,    0,    0,    0,    0,
   15,    0,    0,   14,   33,    0,   32,   36,   19,   17,
    0,   18,    0,   37,    0,   42,   44,    0,    0,    0,
    0,    0,    0,   93,   94,   95,    0,    0,   90,   91,
   92,    0,   46,    0,    0,    0,  103,    0,    0,    0,
  100,    0,   79,    0,   20,    0,   12,    0,    0,    0,
    0,    0,    0,    3,    0,   24,   28,   39,    0,    0,
   77,    0,   75,    0,   89,    0,   74,    0,   64,    0,
   65,    0,    0,    0,   56,   54,    0,   49,   69,   67,
   70,   68,    0,    0,   98,   97,   99,   96,    0,   22,
    0,    0,    0,    9,   16,   34,   76,    0,   87,    0,
   47,   55,    0,    0,  102,   80,    8,   10,   11,   85,
   86,   83,   52,  109,  108,    0,  110,    0,    0,    0,
    0,    0,   58,   57,   53,  104,  105,  106,
};
final static short yydgoto[] = {                         10,
   11,   58,   13,   14,   15,   16,  103,   17,   18,   48,
   19,  105,   20,   65,   21,   22,   23,   24,   25,   33,
   34,  128,  124,   84,  153,  175,  170,   35,   36,   37,
   38,   94,   82,   88,  133,  168,  176,  169,
};
final static short yysindex[] = {                       167,
  -32,  -36,  -33, -237, -227,  -46,    0, -114,    0,    0,
 -224,    0,  197,    0,   18,    0,    8,   77,    0,   30,
    0,    0,   39,   40, -208,    0,    0,    0,    0,   13,
   17,  -26,   49, -187,    0,   -9,    0,    0, -184,    0,
 -154, -150, -225,    0,    0,    0, -145,   95,  -16,   44,
    0, -128,  197,    0,    0,   13,    0,    0,    0,    0,
 -141,    0, -121,    0,  145,    0,    0,   17,   17,  -18,
   10,  142,  146,    0,    0,    0,  -10,  118,    0,    0,
    0,   17,    0,  231,  125,  132,    0,  143,   48,   89,
    0,  -35,    0,  148,    0,  -79,    0,   44,   44,   44,
  -75,  169,   44,    0,  -76,    0,    0,    0,   11,  -40,
    0,  -25,    0,   17,    0,    0,    0,  141,    0,   -9,
    0,   -9,   11,  231,    0,    0,  -57,    0,    0,    0,
    0,    0,  150,   91,    0,    0,    0,    0,  -69,    0,
  189,  -81,  -39,    0,    0,    0,    0,  -30,    0,  -22,
    0,    0,  -58, -108,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,   13,    0,  151,  152,  245,
 -108, -108,    0,    0,    0,    0,    0,    0,
};
final static short yyrindex[] = {                         0,
    0,    0,    0,  112,  115,  -44,    0,    0,    0,    0,
  214,    0,    0,    0,    0,    0,    0,    0,    0,  205,
    0,    0,    1,    0,    0,    0,    0,    0,    0,   41,
    0,    0,    0,  243,    0,   63,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  216,  222,    0,    0,  -44,    0,    0,    0,    0,
  120,    0,  136,    0,    0,    0,    0,    0,    0,    0,
    0,   72,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,   19,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   15,    0,
    0,    0,    0,    0,    0,  158,    0,    0,    0,   86,
    0,  108,  211,    0,    0,    0,  -15,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,  -24,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,
};
final static short yygindex[] = {                         0,
   43,   28,  218,    0,    0,   35,    0,    0,    0,    0,
    0,    0,  210,    0,    0,    0,    0,    0,    0,  416,
    0,  128,    0,    0,    0,    0,    0,  413,  -67,  -59,
    0,    0,   -8,    0,    0,    0,    0, -103,
};
final static int YYTABLESIZE=585;
static short yytable[];
static { yytable();}
static void yytable(){
yytable = new short[]{                         47,
   43,  159,   77,   39,   78,  138,   43,   32,   50,  120,
  122,  158,   77,   70,   78,  117,  107,   77,  162,   78,
   77,   70,   78,  100,   45,  130,  132,   12,   78,   70,
   91,   51,   85,   44,  107,  107,    1,   86,   52,    2,
    3,    4,    5,   45,   92,   54,    6,    7,   68,    8,
   71,   61,   77,   77,   78,   78,   70,   42,   47,   78,
   78,   78,  114,   78,  118,   78,   60,  177,  178,   80,
   81,   79,   61,   45,   99,   83,   59,   78,   78,   78,
   78,   71,   71,   71,  113,   71,   56,   71,   64,   41,
   31,   77,  102,   78,  160,   62,   69,   66,   67,   71,
   71,   71,   71,   61,   69,   61,   98,   61,   80,   81,
   79,  127,   69,   77,   77,   89,   77,   63,   77,   90,
   63,   61,   61,   61,   61,   93,   62,  104,   62,  106,
   62,   77,   77,   77,  113,   62,   54,  145,   96,   69,
  141,  142,  143,   78,   62,   62,   62,   62,   63,  107,
   63,  127,   63,   95,  108,   26,   49,   70,   30,  164,
  165,  155,  166,   25,   70,   71,   63,   63,   63,   63,
   26,   70,  135,   30,   51,   54,   54,   54,   25,   29,
   70,  136,  115,  134,    4,    5,  117,   61,   77,  101,
   78,  140,    8,  139,   29,   46,  146,  174,  152,   76,
   76,  156,   76,  163,   76,   80,   81,   79,  154,  171,
   62,  172,   59,    7,   38,    1,   51,   76,   76,   76,
  137,    4,   40,   27,   46,    9,    4,    5,   53,   72,
  147,  101,   63,  161,    8,   28,   29,  111,   30,   97,
   69,   28,   29,    0,   30,  119,   51,   69,   87,   28,
   29,  151,   30,    0,   69,    0,   43,   28,   29,    0,
   30,   43,   43,   69,   43,   43,    0,   74,   75,   76,
    0,   43,   43,   43,   78,   78,   78,   78,   78,   78,
   78,   78,   78,   78,   28,   29,    0,   30,    0,   78,
   78,    0,    0,  144,    0,    0,   71,    0,   71,   71,
   71,   71,   71,   71,   71,   71,   74,   75,   76,    4,
    5,   71,   71,  157,  101,    0,    0,    8,   61,    0,
   61,   61,   61,   61,   61,   61,   61,   61,    0,   77,
   77,   77,    0,   61,   61,    0,    0,    0,    0,    0,
    0,   62,    0,   62,   62,   62,   62,   62,   62,   62,
   62,    1,    0,    0,    2,    3,   62,   62,    0,    0,
    0,   56,    7,   63,    0,   63,   63,   63,   63,   63,
   63,   63,   63,  121,    0,    0,    0,    0,   63,   63,
  129,    0,    0,    0,    0,   28,   29,  131,   30,    0,
    0,    0,   28,   29,    0,   30,  149,    0,    0,   28,
   29,  116,   30,   74,   75,   76,    0,    0,   28,   29,
    0,   30,   26,   88,    0,   76,   76,   76,   88,   88,
   88,   88,   88,   26,   51,   26,    0,    1,   88,   88,
    2,    3,    4,    5,    4,    5,    0,    6,    7,  101,
    8,    0,    8,    0,   51,    0,   71,   73,    0,    0,
    0,   26,   55,    0,    4,    5,    0,    1,    0,  101,
    2,    3,    8,    0,    0,   26,   84,   56,    7,   57,
    0,   84,   84,   84,   84,   84,    0,    0,    0,    0,
    0,   84,   84,  109,  110,  112,  125,    0,    0,    0,
    0,    1,  126,    0,    2,    3,   26,  123,   48,    0,
  173,   56,    7,   48,   48,    1,   48,   48,    2,    3,
    0,    0,    0,   48,   48,   56,    7,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  148,
    0,    0,    0,  150,    0,    0,   26,    0,    0,    0,
    0,    0,    0,    0,    0,    0,   26,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,  167,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   26,  167,  167,
};
}
static short yycheck[];
static { yycheck(); }
static void yycheck() {
yycheck = new short[] {                         46,
    0,   41,   43,   40,   45,   41,   40,   40,  123,   77,
   78,   93,   43,   40,   45,   41,   41,   43,   41,   45,
   43,   40,   45,   40,   10,   85,   86,    0,   10,   40,
  256,  256,   42,  271,   59,   60,  261,   47,   11,  264,
  265,  266,  267,  271,  270,   11,  271,  272,  257,  274,
   10,   44,   43,   43,   45,   45,   40,   91,   46,   41,
   42,   43,   71,   45,   73,   47,   59,  171,  172,   60,
   61,   62,   10,   59,   91,  263,   59,   59,   60,   61,
   62,   41,   42,   43,  125,   45,  271,   47,   59,  123,
  123,   43,   50,   45,  125,   10,  123,   59,   59,   59,
   60,   61,   62,   41,  123,   43,  123,   45,   60,   61,
   62,   84,  123,   42,   43,  270,   45,   10,   47,  270,
   44,   59,   60,   61,   62,  271,   41,  256,   43,  271,
   45,   60,   61,   62,  125,   59,  102,  103,   44,  123,
   98,   99,  100,  125,   59,   60,   61,   62,   41,  271,
   43,  124,   45,   59,   10,   44,  271,   40,   44,  268,
  269,  134,  271,   44,   40,  125,   59,   60,   61,   62,
   59,   40,  125,   59,  256,  141,  142,  143,   59,   44,
   40,   93,   41,   41,  266,  267,   41,  125,   43,  271,
   45,  271,  274,   46,   59,  271,  273,  170,  256,   42,
   43,  271,   45,  262,   47,   60,   61,   62,   59,   59,
  125,   60,  257,    0,   10,    0,  256,   60,   61,   62,
  256,    0,  256,  256,  271,   59,  266,  267,   11,  256,
  256,  271,  125,  256,  274,  268,  269,  256,  271,  256,
  123,  268,  269,   -1,  271,  256,  262,  123,   39,  268,
  269,  124,  271,   -1,  123,   -1,  256,  268,  269,   -1,
  271,  261,  262,  123,  264,  265,   -1,  258,  259,  260,
   -1,  271,  272,  273,  256,  257,  258,  259,  260,  261,
  262,  263,  264,  265,  268,  269,   -1,  271,   -1,  271,
  272,   -1,   -1,  125,   -1,   -1,  256,   -1,  258,  259,
  260,  261,  262,  263,  264,  265,  258,  259,  260,  266,
  267,  271,  272,  125,  271,   -1,   -1,  274,  256,   -1,
  258,  259,  260,  261,  262,  263,  264,  265,   -1,  258,
  259,  260,   -1,  271,  272,   -1,   -1,   -1,   -1,   -1,
   -1,  256,   -1,  258,  259,  260,  261,  262,  263,  264,
  265,  261,   -1,   -1,  264,  265,  271,  272,   -1,   -1,
   -1,  271,  272,  256,   -1,  258,  259,  260,  261,  262,
  263,  264,  265,  256,   -1,   -1,   -1,   -1,  271,  272,
  256,   -1,   -1,   -1,   -1,  268,  269,  256,  271,   -1,
   -1,   -1,  268,  269,   -1,  271,  256,   -1,   -1,  268,
  269,  256,  271,  258,  259,  260,   -1,   -1,  268,  269,
   -1,  271,    0,  256,   -1,  258,  259,  260,  261,  262,
  263,  264,  265,   11,  256,   13,   -1,  261,  271,  272,
  264,  265,  266,  267,  266,  267,   -1,  271,  272,  271,
  274,   -1,  274,   -1,  256,   -1,   31,   32,   -1,   -1,
   -1,   39,  256,   -1,  266,  267,   -1,  261,   -1,  271,
  264,  265,  274,   -1,   -1,   53,  256,  271,  272,  273,
   -1,  261,  262,  263,  264,  265,   -1,   -1,   -1,   -1,
   -1,  271,  272,   68,   69,   70,  256,   -1,   -1,   -1,
   -1,  261,  262,   -1,  264,  265,   84,   82,  256,   -1,
  256,  271,  272,  261,  262,  261,  264,  265,  264,  265,
   -1,   -1,   -1,  271,  272,  271,  272,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  114,
   -1,   -1,   -1,  118,   -1,   -1,  124,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,  134,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,  154,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,  170,  171,  172,
};
}
final static short YYFINAL=10;
final static short YYMAXTOKEN=274;
final static String yyname[] = {
"end-of-file",null,null,null,null,null,null,null,null,null,"'\\n'",null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,"'('","')'","'*'","'+'",
"','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,null,
"';'","'<'","'='","'>'",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,"ASIG","MAYOR_IGUAL","MENOR_IGUAL",
"DIFERENTE","IF","ELSE","THEN","FOR","PRINT","ULONGINT","UINTEGER","CONST_UI",
"CONST_UL","CADENA","IDENTIFICADOR","BEGIN","END","STRUCT",
};
final static String yyrule[] = {
"$accept : programa",
"programa : declaraciones bloque",
"programa : bloque",
"programa : declaraciones bloque error",
"programa : declaraciones bloque_open",
"programa : programaInvalido",
"programaInvalido : ';'",
"programaInvalido : declaraciones",
"tipo_estructura : STRUCT IDENTIFICADOR '{' declaraciones '}'",
"tipo_estructura : STRUCT '{' declaraciones '}'",
"tipo_estructura : STRUCT IDENTIFICADOR '[' declaraciones ']'",
"tipo_estructura : STRUCT IDENTIFICADOR '(' declaraciones ')'",
"tipo_estructura : STRUCT IDENTIFICADOR error",
"declaraciones : declaracion",
"declaraciones : declaraciones declaracion",
"$$1 :",
"declaraciones : declaraciones error $$1 declaracion",
"declaracion : declaracion_ulongint ';'",
"declaracion : declaracion_uinteger ';'",
"declaracion : tipo_estructura ';'",
"declaracion : IDENTIFICADOR declaracion_estructura ';'",
"declaracion_estructura : IDENTIFICADOR",
"declaracion_estructura : declaracion_estructura ',' IDENTIFICADOR",
"declaracion_ulongint : ULONGINT IDENTIFICADOR",
"declaracion_ulongint : declaracion_ulongint ',' IDENTIFICADOR",
"declaracion_ulongint : declaracion_ulongint ','",
"declaracion_ulongint : ULONGINT",
"declaracion_uinteger : UINTEGER IDENTIFICADOR",
"declaracion_uinteger : declaracion_uinteger ',' IDENTIFICADOR",
"declaracion_uinteger : declaracion_uinteger ','",
"declaracion_uinteger : UINTEGER",
"bloque : sentencia",
"bloque : bloque_open END",
"$$2 :",
"bloque : bloque_open error $$2 END",
"bloque_open : BEGIN",
"bloque_open : bloque_open bloque",
"sentencia : asignacion ';'",
"$$3 :",
"sentencia : asignacion $$3 '\\n'",
"sentencia : seleccion",
"sentencia : iteracion",
"sentencia : impresion ';'",
"sentencia : impresion",
"sentencia : impresion_err ';'",
"asignacion : elementoAsignable ASIG expresion",
"$$4 :",
"seleccion : IF condicion THEN $$4 seleccion_else",
"$$5 :",
"seleccion : IF condicion $$5 seleccion_else",
"seleccion : IF error",
"$$6 :",
"$$7 :",
"seleccion_else : bloque $$6 ELSE $$7 seleccion_fin",
"seleccion_else : ELSE",
"seleccion_else : bloque error",
"seleccion_else : error",
"seleccion_fin : bloque",
"seleccion_fin : error",
"elementoAsignable : IDENTIFICADOR",
"elementoAsignable : elemento_estructura",
"expresion : termino",
"expresion : expresion '+' termino",
"expresion : expresion '-' termino",
"expresion : expresion '+' error",
"expresion : expresion '-' error",
"termino : factor",
"termino : termino '*' factor",
"termino : termino '/' factor",
"termino : termino '*' error",
"termino : termino '/' error",
"factor : IDENTIFICADOR",
"factor : constante",
"factor : elemento_estructura",
"factor : '(' expresion ')'",
"factor : '{' expresion '}'",
"factor : '(' expresion error",
"factor : '(' error",
"elemento_estructura : IDENTIFICADOR '.' campo_estructura",
"campo_estructura : IDENTIFICADOR",
"campo_estructura : campo_estructura '.' IDENTIFICADOR",
"constante : CONST_UL",
"constante : CONST_UI",
"condicion : '(' expresion operador_logico expresion ')'",
"condicion : expresion operador_logico expresion",
"condicion : '{' expresion operador_logico expresion '}'",
"condicion : '(' expresion operador_logico expresion error",
"condicion : '(' expresion operador_logico error",
"condicion : '(' expresion error",
"condicion : '(' error ')'",
"operador_logico : '>'",
"operador_logico : '<'",
"operador_logico : '='",
"operador_logico : MAYOR_IGUAL",
"operador_logico : MENOR_IGUAL",
"operador_logico : DIFERENTE",
"impresion : PRINT '(' CADENA ')'",
"impresion_err : PRINT '[' CADENA ']'",
"impresion_err : PRINT '{' CADENA '}'",
"impresion_err : PRINT '(' CADENA error",
"impresion_err : PRINT '(' error",
"impresion_err : PRINT error",
"iteracion : FOR '(' controlFor ')' bloque",
"$$8 :",
"controlFor : asignacion $$8 ';' comparacion ';' incremento",
"incremento : entero",
"comparacion : entero '<' entero",
"entero : IDENTIFICADOR",
"entero : CONST_UL",
"entero : CONST_UI",
"entero : elemento_estructura",
};

//#line 481 "GramaticaFinal.y"

AnalizadorLexico al;    // Analizador Lexico
TSimbolo ts;		// Tabla de Simbolos
Polaca P;            	// Polaca

public Parser(AnalizadorLexico al, TSimbolo ts)
{
  this.al = al;
  this.ts = ts;
  this.P = new Polaca(this.ts);
}

void yyout(String texto) {
    Mensaje msj = new Mensaje("linea " + al.get_num_lineas() + " - " + texto, Mensaje.SENT);
    setChanged();
    notifyObservers(msj);
}

void yyerror(String texto) {
    Mensaje msj = new Mensaje("ERROR SINTACTICO: linea " + al.get_num_lineas() + " - " + texto, Mensaje.INF);
    setChanged();
    notifyObservers(msj);
}


short yylex() throws FileNotFoundException, IOException{
    Token token = al.obtener_token();
    Mensaje msj = new Mensaje(token.toString()+"\n", Mensaje.TOKEN);
    setChanged();
    notifyObservers(msj);
    yylval = new ParserVal(token);
    return token.traducir();
}


Token getToken(ParserVal val){
    return val.elemento_token;
}

public Polaca getPolaca() {
        return this.P;
    }


//#line 529 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
  if (ch < 0) ch=0;
  if (ch <= YYMAXTOKEN) //check index bounds
     s = yyname[ch];    //now get it
  if (s==null)
    s = "illegal-symbol";
  debug("state "+state+", reading "+ch+" ("+s+")");
}





//The following are now global, to aid in error reporting
int yyn;       //next next thing to do
int yym;       //
int yystate;   //current parsing state from state table
String yys;    //current token string


//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
throws IOException,FileNotFoundException
{
boolean doaction;
  init_stacks();
  yynerrs = 0;
  yyerrflag = 0;
  yychar = -1;          //impossible char forces a read
  yystate=0;            //initial state
  state_push(yystate);  //save it
  val_push(yylval);     //save empty value
  while (true) //until parsing is done, either correctly, or w/error
    {
    doaction=true;
    if (yydebug) debug("loop"); 
    //#### NEXT ACTION (from reduction table)
    for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
      {
      if (yydebug) debug("yyn:"+yyn+"  state:"+yystate+"  yychar:"+yychar);
      if (yychar < 0)      //we want a char?
        {
        yychar = yylex();  //get next token
        if (yydebug) debug(" next yychar:"+yychar);
        //#### ERROR CHECK ####
        if (yychar < 0)    //it it didn't work/error
          {
          yychar = 0;      //change it to default string (no -1!)
          if (yydebug)
            yylexdebug(yystate,yychar);
          }
        }//yychar<0
      yyn = yysindex[yystate];  //get amount to shift by (shift index)
      if ((yyn != 0) && (yyn += yychar) >= 0 &&
          yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
        {
        if (yydebug)
          debug("state "+yystate+", shifting to state "+yytable[yyn]);
        //#### NEXT STATE ####
        yystate = yytable[yyn];//we are in a new state
        state_push(yystate);   //save it
        val_push(yylval);      //push our lval as the input for next rule
        yychar = -1;           //since we have 'eaten' a token, say we need another
        if (yyerrflag > 0)     //have we recovered an error?
           --yyerrflag;        //give ourselves credit
        doaction=false;        //but don't process yet
        break;   //quit the yyn=0 loop
        }

    yyn = yyrindex[yystate];  //reduce
    if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
      {   //we reduced!
      if (yydebug) debug("reduce");
      yyn = yytable[yyn];
      doaction=true; //get ready to execute
      break;         //drop down to actions
      }
    else //ERROR RECOVERY
      {
      if (yyerrflag==0)
        {
        yyerror("syntax error");
        yynerrs++;
        }
      if (yyerrflag < 3) //low error count?
        {
        yyerrflag = 3;
        while (true)   //do until break
          {
          if (stateptr<0)   //check for under & overflow here
            {
            yyerror("stack underflow. aborting...");  //note lower case 's'
            return 1;
            }
          yyn = yysindex[state_peek(0)];
          if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
            if (yydebug)
              debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
            yystate = yytable[yyn];
            state_push(yystate);
            val_push(yylval);
            doaction=false;
            break;
            }
          else
            {
            if (yydebug)
              debug("error recovery discarding state "+state_peek(0)+" ");
            if (stateptr<0)   //check for under & overflow here
              {
              yyerror("Stack underflow. aborting...");  //capital 'S'
              return 1;
              }
            state_pop();
            val_pop();
            }
          }
        }
      else            //discard this token
        {
        if (yychar == 0)
          return 1; //yyabort
        if (yydebug)
          {
          yys = null;
          if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
          if (yys == null) yys = "illegal-symbol";
          debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
          }
        yychar = -1;  //read another
        }
      }//end error recovery
    }//yyn=0 loop
    if (!doaction)   //any reason not to proceed?
      continue;      //skip action
    yym = yylen[yyn];          //get count of terminals on rhs
    if (yydebug)
      debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
    if (yym>0)                 //if count of rhs not 'nil'
      yyval = val_peek(yym-1); //get current semantic value
    yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value
    switch(yyn)
      {
//########## USER-SUPPLIED ACTIONS ##########
case 1:
//#line 21 "GramaticaFinal.y"
{this.ts.clean();}
break;
case 2:
//#line 22 "GramaticaFinal.y"
{this.ts.clean();}
break;
case 3:
//#line 23 "GramaticaFinal.y"
{yyerror("Programa: se esperaba fin de archivo luego de bloque principal");}
break;
case 4:
//#line 24 "GramaticaFinal.y"
{yyerror("Programa: se esperaba \"END\" luego de la ultima sentencia");}
break;
case 6:
//#line 28 "GramaticaFinal.y"
{yyerror("El programa no respeta las sintaxis \"<declaraciones> <bloque>\" ");}
break;
case 7:
//#line 29 "GramaticaFinal.y"
{yyerror("El programa no respeta las sintaxis \"<declaraciones> <bloque>\" ");}
break;
case 8:
//#line 33 "GramaticaFinal.y"
{yyout("Declaracion ESTRUCTURA " + val_peek(3).elemento_token.getCadena() + " como tipo");
										    
										    Token_Struct Est = new Token_Struct (val_peek(3).elemento_token.getCadena());
										    Est.agregarElementos(val_peek(1).lista);
										    /*Aca tendria que ver de eliminar los elementos de la tabla que pasan a ser parte de la estructura...*/
										    this.ts.eliminarTokens (val_peek(1).lista);
										    /*this.ts.set(Est);*/
										    if (this.ts.set(Est)){
                                                                                                           yyerror("ERROR: Identificador duplicado->: " + Est.getCadena()); 
                                                
                                                                                    }
										    
										    ArrayList<Token> lista = new ArrayList<Token>();
										    lista.add(Est);
										    yyval = new ParserVal (lista);
										    }
break;
case 9:
//#line 50 "GramaticaFinal.y"
{yyerror("Declaracion ESTUCTURA: falta nombre de la Estructura");}
break;
case 10:
//#line 51 "GramaticaFinal.y"
{yyerror("Declaracion ESTRUCTURA : se esperaba {} en lugar de []");}
break;
case 11:
//#line 52 "GramaticaFinal.y"
{yyerror("Declaracion ESTRUCTURA : se esperaba {} en lugar de ()");}
break;
case 12:
//#line 53 "GramaticaFinal.y"
{yyerror("Declaracion ESTRUCTURA: se esperaban llaves");}
break;
case 13:
//#line 57 "GramaticaFinal.y"
{ yyval = val_peek(0); }
break;
case 14:
//#line 58 "GramaticaFinal.y"
{ ArrayList<Token> listad = val_peek(1).lista; listad.addAll(val_peek(0).lista); yyval = new ParserVal (listad); }
break;
case 15:
//#line 59 "GramaticaFinal.y"
{yyerror("Declaracion: sentencia incorrecta");}
break;
case 17:
//#line 63 "GramaticaFinal.y"
{yyval = val_peek(1); }
break;
case 18:
//#line 64 "GramaticaFinal.y"
{yyval = val_peek(1); }
break;
case 19:
//#line 65 "GramaticaFinal.y"
{yyval = val_peek(1); }
break;
case 20:
//#line 67 "GramaticaFinal.y"
{
					
					yyout("Declaracion de variables del tipo ESTRUCTURA " + val_peek(2).elemento_token.getCadena());
					    
					/*Ver que exista la definicion del la estructura con ese nombre en la tabla de simbolos, si no error*/
					String nombreIdentificador = val_peek(2).elemento_token.getCadena();
					

					if ((this.ts.existeToken(nombreIdentificador)) && (this.ts.get(nombreIdentificador).getId().equals(Tokens.struct))){
					    
					    /*Crear uno nuevo y clonarlo!!! al tipo de la tabla con el nombre de estructura nombreIdentificador*/
	
					   ArrayList variablesTipoEst = new ArrayList (); 
					   for(Iterator it = val_peek(1).lista.iterator(); it.hasNext(); ){
						    
						Token tipoEstructura = (Token_Struct)((Token_Struct)this.ts.get(nombreIdentificador)).clone();
						Token e = (Token) it.next();
						tipoEstructura.setCadena(e.getCadena());
						tipoEstructura.setPadre((Token_Identificador)this.ts.get(nombreIdentificador));
						/*this.ts.set(tipoEstructura);*/
						if (this.ts.set(tipoEstructura)){
                                                                                    yyerror("ERROR: Identificador duplicado->: " + tipoEstructura.getCadena()); 
                                                
                                                }
						variablesTipoEst.add(tipoEstructura);

						}
		
					   yyval = new ParserVal (variablesTipoEst);						    
					   }else{
						  
							yyerror ("ERROR SINTACTICO: Tipo STRUCT o Tipo: " + nombreIdentificador + " no EXISTE");					
							ArrayList error = new ArrayList ();
							error.add(val_peek(2).elemento_token);							
							yyval = new ParserVal (error);
						 };
					
					}
break;
case 21:
//#line 109 "GramaticaFinal.y"
{ 
					  		ArrayList listaTokens = new ArrayList();
					    		listaTokens.add(val_peek(0).elemento_token);
					    		/*La Izquierdo se vuelve lado derecho...*/
					    		yyval = new ParserVal(listaTokens);
					    		}
break;
case 22:
//#line 116 "GramaticaFinal.y"
{
										  val_peek(2).lista.add(val_peek(0).elemento_token);
										  yyval = val_peek(2);
										 }
break;
case 23:
//#line 123 "GramaticaFinal.y"
{yyout("Declaracion ULONGINT");

					    /*Obtengo el nombre la cadena del Identificador que va a ser el nombre de la Variable UInteger*/
					    String nombreIdentificador = val_peek(0).elemento_token.getCadena();
					    
					    /*Creo un entero del tipo correspondiente*/
					    Token entero = new Token_Ulongint();
					    
					    /*Creo variable con el nombre Identificador y un tipo entero sin valor, dado que no fue aun asignado*/
					    Token variable = new Token_Variable(nombreIdentificador, entero);
					    
					    /*Actualizo la tabla de simbolos*/
					    /*this.ts.set(variable);*/
					    if (this.ts.set(variable)){
                                                                        yyerror("ERROR SINTACTICO: Identificador duplicado->: " + variable.getCadena()); 
                                                
                                            }

					    
					    /*Agrego en una lista de elementos auxiliar...*/
					    ArrayList listaTokens = new ArrayList();
					    listaTokens.add(variable);
					    
					    /*La Izquierda se vuelve lado derecho...*/
					    yyval = new ParserVal(listaTokens);
				}
break;
case 24:
//#line 150 "GramaticaFinal.y"
{yyout("Declaracion ULONGINT");

					    /*Obtengo el nombre la cadena del Identificador que va a ser el nombre de la Variable UInteger*/
					    String nombreIdentificador = val_peek(0).elemento_token.getCadena();
					    
					    /*Creo un entero del tipo correspondiente*/
					    Token entero = new Token_Ulongint();
					    
					    /*Creo variable con el nombre Identificador y un tipo entero sin valor, dado que no fue aun asignado*/
					    Token variable = new Token_Variable(nombreIdentificador, entero);
					    
					    /*Actualizo la tabla de simbolos*/
					    /*this.ts.set(variable);*/
					    if (this.ts.set(variable)){
                                                                        yyerror("ERROR SINTACTICO: Identificador duplicado->: " + variable.getCadena()); 
                                                
                                            }
					    
					    /*Obtengo la lista y agrego el nuevo elemento...*/
					    val_peek(2).lista.add(variable);
					    
					    /*El no terminal Izquierdo se vuevle los elementos del derecho...*/
					    yyval = val_peek(2);

				}
break;
case 25:
//#line 176 "GramaticaFinal.y"
{yyerror("Declaracion ULONGINT: se esperaba identificador luego de \",\"");}
break;
case 26:
//#line 177 "GramaticaFinal.y"
{yyerror("Declaracion ULONGINT: se esperaba identificador luego de palabra reservada ULONGINT");}
break;
case 27:
//#line 183 "GramaticaFinal.y"
{yyout("Declaracion INTEGER");

					    /*Obtengo el nombre la cadena del Identificador que va a ser el nombre de la Variable UInteger*/
					    String nombreIdentificador = val_peek(0).elemento_token.getCadena();
					    
					    /*Creo un entero del tipo correspondiente*/
					    Token entero = new Token_Uinteger();
					    
					    /*Creo variable con el nombre Identificador y un tipo entero sin valor, dado que no fue aun asignado*/
					    Token variable = new Token_Variable(nombreIdentificador, entero);
					    
					    /*Actualizo la tabla de simbolos*/
					    /*this.ts.set(variable);*/
					    if (this.ts.set(variable)){
                                                                         yyerror("ERROR SINTACTICO: Identificador duplicado -> " + variable.getCadena()); 
                                                
                                            }
					    /*Agrego en una lista de elementos auxiliar...*/
					    ArrayList listaTokens = new ArrayList();
					    listaTokens.add(variable);
					    
					    /*La Izquierda se vuelve lado derecho...*/
					    yyval = new ParserVal(listaTokens);
				}
break;
case 28:
//#line 208 "GramaticaFinal.y"
{yyout("Declaracion INTEGER");

					    /*Obtengo el nombre la cadena del Identificador que va a ser el nombre de la Variable UInteger*/
					    String nombreIdentificador = val_peek(0).elemento_token.getCadena();
					    
					    /*Creo un entero del tipo correspondiente*/
					    Token entero = new Token_Uinteger();
					    
					    /*Creo variable con el nombre Identificador y un tipo entero sin valor, dado que no fue aun asignado*/
					    Token variable = new Token_Variable(nombreIdentificador, entero);
					    
					    /*Actualizo la tabla de simbolos*/
					    /*this.ts.set(variable);*/
					    if (this.ts.set(variable)){
                                                                        yyerror("ERROR SINTACTICO: Identificador duplicado -> " + variable.getCadena()); 
                                                
                                            }
					    /*Obtengo la lista y agrego el nuevo elemento...*/
					    val_peek(2).lista.add(variable);
					    
					    /*El no terminal Izquierdo se vuevle los elementos del derecho...*/
					    yyval = val_peek(2);

				}
break;
case 29:
//#line 233 "GramaticaFinal.y"
{yyerror("Declaracion INTEGER: se esperaba identificador luego de \",\"");}
break;
case 30:
//#line 234 "GramaticaFinal.y"
{yyerror("Declaracion INTEGER: se esperaba identificador luego de palabra reservada ULONGINT");}
break;
case 33:
//#line 241 "GramaticaFinal.y"
{yyerror("Bloque: sentencia incorrecta");}
break;
case 38:
//#line 251 "GramaticaFinal.y"
{yyerror("Asignacion: se esperaba \";\"");}
break;
case 43:
//#line 255 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba \";\"");}
break;
case 45:
//#line 260 "GramaticaFinal.y"
{	yyout ("Asignacion");
                                                                     		P.addElementos(val_peek(2).lista);
                                                                     		P.addElemento(new Token_Asignacion ());
										yyval = val_peek(2); /* para el for */
								     	  }
break;
case 46:
//#line 269 "GramaticaFinal.y"
{yyout("--- Seleccion IF ---");}
break;
case 48:
//#line 270 "GramaticaFinal.y"
{yyout("--- Seleccion IF ---"); yyerror("Seleccion: Se esperaba THEN luego de condicion");}
break;
case 50:
//#line 271 "GramaticaFinal.y"
{yyerror("Seleccion: se esperaba condicion luego de palabra reservada IF");}
break;
case 51:
//#line 275 "GramaticaFinal.y"
{
						int posicionPrincipioELSE = P.posActual()+3; P.escribir((Integer)P.desapilar(), new Token_Pos(posicionPrincipioELSE)); 							P.apilar(P.posActual()+1); 
						P.addElemento(new Token_Pos(-1)); P.addElemento(new Token (Tokens.salto_incondicional)); 
						
					      }
break;
case 52:
//#line 280 "GramaticaFinal.y"
{yyout("--- Seleccion ELSE ---");}
break;
case 54:
//#line 281 "GramaticaFinal.y"
{yyout("--- Seleccion ELSE ---"); yyerror("Seleccion: se esperaba bloque luego de condicion");}
break;
case 55:
//#line 282 "GramaticaFinal.y"
{yyout("--- Fin de seleccion ---"); yyerror("Seleccion: se esperaba palabra reservada ELSE luego de bloque");}
break;
case 56:
//#line 283 "GramaticaFinal.y"
{yyout("--- Fin de seleccion ---"); yyerror("Seleccion: se esperaba bloque luego de condicion");}
break;
case 57:
//#line 286 "GramaticaFinal.y"
{yyout("--- Fin de seleccion ---");
						int posicionFinIFELSE = P.posActual()+1;
						P.escribir((Integer)P.desapilar(),new Token_Pos(posicionFinIFELSE));
					       }
break;
case 58:
//#line 291 "GramaticaFinal.y"
{yyout("--- Fin de seleccion ---"); yyerror("Seleccion: se esperaba bloque luego de palabra reservada ELSE");}
break;
case 59:
//#line 294 "GramaticaFinal.y"
{ ArrayList listaT = new ArrayList ();
    							listaT.add(val_peek(0).elemento_token);
    							yyval = new ParserVal (listaT);
							}
break;
case 60:
//#line 298 "GramaticaFinal.y"
{yyval = val_peek(0);}
break;
case 62:
//#line 304 "GramaticaFinal.y"
{
								/*HH Crear un Token + Polaca.escribir(Token +)*/
								P.addElemento (new Token_OperadorSuma());								
							      }
break;
case 63:
//#line 308 "GramaticaFinal.y"
{
								/*HH Crear un Token - Polaca.escribir(Token -)*/
							        P.addElemento (new Token_OperadorResta());
							      }
break;
case 64:
//#line 312 "GramaticaFinal.y"
{yyerror("Expresion: se esperaba un termino luego de \"+\"");}
break;
case 65:
//#line 313 "GramaticaFinal.y"
{yyerror("Expresion: se esperaba un termino luego de \"-\"");}
break;
case 67:
//#line 317 "GramaticaFinal.y"
{
							    /*HH Crear un Token * y Polaca.escribir(Token *)*/
							    P.addElemento (new Token_OperadorMul());
							   }
break;
case 68:
//#line 321 "GramaticaFinal.y"
{
							    /*HH Crear un Token / y Polaca.escribir(Token /)					    */
							    P.addElemento (new Token_OperadorDiv());
							   }
break;
case 69:
//#line 326 "GramaticaFinal.y"
{yyerror("Termino: se esperaba un factor luego de \"*\"");}
break;
case 70:
//#line 327 "GramaticaFinal.y"
{yyerror("Termino: se esperaba un factor luego de \"/\"");}
break;
case 71:
//#line 330 "GramaticaFinal.y"
{
							/* Polaca.escribir(Token IDENTIFICADOR) */
							P.addElemento (val_peek(0).elemento_token);
						      }
break;
case 72:
//#line 334 "GramaticaFinal.y"
{
							/* Polaca.escribir(Token constante)*/
							P.addElemento (val_peek(0).elemento_token);
						  }
break;
case 73:
//#line 338 "GramaticaFinal.y"
{
							     /*Polaca.escribir(Token ElementoEstrucutra)*/
							     P.addElementos(val_peek(0).lista);
							    }
break;
case 75:
//#line 343 "GramaticaFinal.y"
{yyerror("Factor: se esperaba \"(\" y \")\" en lugar de \"{\" y \"}\"");}
break;
case 76:
//#line 344 "GramaticaFinal.y"
{yyerror("Factor: se esperaba \")\" luego de expresion");}
break;
case 77:
//#line 345 "GramaticaFinal.y"
{yyerror("Factor: se esperaba expresion luego de \"(\"");}
break;
case 78:
//#line 349 "GramaticaFinal.y"
{
									    ArrayList listaEst = new ArrayList();
									    listaEst.add(val_peek(2).elemento_token);
									    listaEst.addAll(val_peek(0).lista);
									    listaEst.add(new Token_Punto());
									    yyval = new ParserVal (listaEst);
									   }
break;
case 79:
//#line 359 "GramaticaFinal.y"
{
							ArrayList ElementosEstructura = new ArrayList ();
							ElementosEstructura.add(val_peek(0).elemento_token);
							yyval = new ParserVal (ElementosEstructura);
						        
						       }
break;
case 80:
//#line 365 "GramaticaFinal.y"
{
/*HH Crear un Token '.' Polaca.escribir(campo_estrucutra), Polaca.escribir(Token ID), Polaca.escribir('.')*/
									   /* Agergo X,b,.*/
									   val_peek(2).lista.add(val_peek(0).elemento_token); 
									   val_peek(2).lista.add(new Token_Punto());
									   yyval = val_peek(2);
	
									   }
break;
case 81:
//#line 375 "GramaticaFinal.y"
{ yyval = val_peek(0);}
break;
case 82:
//#line 376 "GramaticaFinal.y"
{ yyval = val_peek(0);}
break;
case 83:
//#line 381 "GramaticaFinal.y"
{ 
											P.addElemento (new Token_Cmp());
											P.addElemento (new Token_Pos(-1111));
											P.apilar(P.posActual());
											P.addElemento (val_peek(2).elemento_token);
											}
break;
case 84:
//#line 387 "GramaticaFinal.y"
{yyerror("Condicion: se esperaba \"(\" y \")\"");}
break;
case 85:
//#line 388 "GramaticaFinal.y"
{yyerror("Condicion: se esperaba \"(\" y \")\" en lugar de \"{\" y \"}\"");}
break;
case 86:
//#line 389 "GramaticaFinal.y"
{yyerror("Condicion: se esperaba \")\" luego de expresion");}
break;
case 87:
//#line 390 "GramaticaFinal.y"
{yyerror("Condicion: se esperaba expresion luego de operador logico");}
break;
case 88:
//#line 391 "GramaticaFinal.y"
{yyerror("Condicion: se esperaba operador logico");}
break;
case 89:
//#line 392 "GramaticaFinal.y"
{yyerror("Condicion: condición lógica no válida");}
break;
case 90:
//#line 395 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.menor_igual));}
break;
case 91:
//#line 396 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.mayor_igual));}
break;
case 92:
//#line 397 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.distinto));}
break;
case 93:
//#line 398 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.menor));}
break;
case 94:
//#line 399 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.mayor));}
break;
case 95:
//#line 400 "GramaticaFinal.y"
{yyval = new ParserVal(new Token(Tokens.igual));}
break;
case 96:
//#line 404 "GramaticaFinal.y"
{
								yyout("Impresion (" + val_peek(1).elemento_token.getCadena() + ")");
								P.addElemento(val_peek(1).elemento_token);
								P.addElemento(new Token_Print());
								}
break;
case 97:
//#line 411 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba \"(\" y \")\" en lugar de \"[\" y \"]\"");}
break;
case 98:
//#line 412 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba \"(\" y \")\" en lugar de \"{\" y \"}\"");}
break;
case 99:
//#line 413 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba \")\" luego de cadena");}
break;
case 100:
//#line 414 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba cadena luego de \"(\"");}
break;
case 101:
//#line 415 "GramaticaFinal.y"
{yyerror("Impresion: se esperaba \"(\" luego de palabra reservada PRINT");}
break;
case 102:
//#line 419 "GramaticaFinal.y"
{/* creo token_pos(con posicion comienzocondicion o 										sea desapilo) desapiloTokenPos y le seteo la 										posicion fin de bloque creo toquenBI  */
															
									yyout("Fin de Bloque FOR"); 
									int posicionCondicionPorFalso =	(Integer)P.desapilar(); 
									P.addElementos(val_peek(2).lista);
						/*P.addElemento(new Token_OperadorSuma());									*/
									P.addElemento(new Token_Pos((Integer)P.desapilar())); 
									P.addElemento(new Token (Tokens.salto_incondicional)); 
									P.escribir(posicionCondicionPorFalso, new Token_Pos(P.posActual()+1));
														
									}
break;
case 103:
//#line 432 "GramaticaFinal.y"
{  P.apilar(P.posActual()+1); }
break;
case 104:
//#line 433 "GramaticaFinal.y"
{
					ArrayList listaT = new ArrayList ();
					listaT.addAll(val_peek(5).lista);
					listaT.addAll(val_peek(0).lista);
					listaT.add(new Token_Operador());
					listaT.addAll(val_peek(5).lista);
					listaT.add(new Token_Asignacion());
					yyval = new ParserVal (listaT);			
				}
break;
case 105:
//#line 445 "GramaticaFinal.y"
{
					yyval = new ParserVal(val_peek(0).lista);					
				       }
break;
case 106:
//#line 450 "GramaticaFinal.y"
{/*creo CMP, apiloposDeTokenPos, creo token_pos, creoBLT*/
							P.addElementos(val_peek(2).lista);
							P.addElementos(val_peek(0).lista);
							P.addElemento(new Token_Cmp()); 
							P.addElemento(new Token_Pos(-1111)); 
							P.apilar(P.posActual()); 
							P.addElemento(new Token(Tokens.mayor_igual));
						    }
break;
case 107:
//#line 462 "GramaticaFinal.y"
{ ArrayList listaT = new ArrayList ();
    							listaT.add(val_peek(0).elemento_token);
    							yyval = new ParserVal (listaT);
							/*P.addElemento($1.elemento_token);*/
						      }
break;
case 108:
//#line 467 "GramaticaFinal.y"
{ArrayList listaT = new ArrayList ();
    						  listaT.add(val_peek(0).elemento_token);
					          yyval = new ParserVal (listaT);
						  /*P.addElemento ($1.elemento_token);*/
						 }
break;
case 109:
//#line 472 "GramaticaFinal.y"
{ArrayList listaT = new ArrayList ();
    						  listaT.add(val_peek(0).elemento_token);
					          yyval = new ParserVal (listaT);
						  /*P.addElemento ($1.elemento_token);*/
						 }
break;
case 110:
//#line 477 "GramaticaFinal.y"
{yyval = val_peek(0);}
break;
//#line 1298 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
    }//switch
    //#### Now let's reduce... ####
    if (yydebug) debug("reduce");
    state_drop(yym);             //we just reduced yylen states
    yystate = state_peek(0);     //get new state
    val_drop(yym);               //corresponding value drop
    yym = yylhs[yyn];            //select next TERMINAL(on lhs)
    if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
      {
      if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
      yystate = YYFINAL;         //explicitly say we're done
      state_push(YYFINAL);       //and save it
      val_push(yyval);           //also save the semantic value of parsing
      if (yychar < 0)            //we want another character?
        {
        yychar = yylex();        //get next character
        if (yychar<0) yychar=0;  //clean, if necessary
        if (yydebug)
          yylexdebug(yystate,yychar);
        }
      if (yychar == 0)          //Good exit (if lex returns 0 ;-)
         break;                 //quit the loop--all DONE
      }//if yystate
    else                        //else not done yet
      {                         //get next state and push, for next yydefred[]
      yyn = yygindex[yym];      //find out where to go
      if ((yyn != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn]; //get new state
      else
        yystate = yydgoto[yym]; //else go to new defred
      if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
      state_push(yystate);     //going again, so push state & val...
      val_push(yyval);         //for next action
      }
    }//main loop
  return 0;//yyaccept!!
}
//## end of method parse() ######################################



//## run() --- for Thread #######################################
/**
 * A default run method, used for operating this parser
 * object in the background.  It is intended for extending Thread
 * or implementing Runnable.  Turn off with -Jnorun .
 */
public void run()
{
  yyparse();
}
//## end of method run() ########################################



//## Constructors ###############################################
/**
 * Default constructor.  Turn off with -Jnoconstruct .

 */
public Parser()
{
  //nothing to do
}


/**
 * Create a parser, setting the debug to true or false.
 * @param debugMe true for debugging, false for no debug.
 */
public Parser(boolean debugMe)
{
  yydebug=debugMe;
}
//###############################################################



}
//################### END OF CLASS ##############################
